<%@ page import="com.sand.util.DateTool" %>
<%@ page import="java.util.Date" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>我的钱包</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/renting/css/public.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/renting/css/layui.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/renting/css/header.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/renting/css/bottom.css"/>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/renting/css/tenant_public.css"/>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/renting/css/tenant_wallet.css"/>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/renting/css/landlord_wallet.css"/>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/renting/css/tenant_public.css"/>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/renting/css/tenant_contract.css"/>

</head>
<body>
<div class="header">
    <div class="nav">
        <a href="${pageContext.request.contextPath}/renting/index.jsp" class="nav_title">好客租房</a>
        <select class="select">
            <option value="重庆">重庆</option>
            <option value="贵阳">贵阳</option>
            <option value="重庆">重庆</option>
            <option value="贵阳">贵阳</option>
        </select>
        <ul class="nav_ul">
            <li><a href="${pageContext.request.contextPath}/renting/index.jsp">首页</a></li>
            <li><a href="${pageContext.request.contextPath}/renting/pages/onther/Findroom.jsp">轻松找房</a></li>
            <li><a href="${pageContext.request.contextPath}/renting/pages/onther/entry.jsp">房东入驻</a></li>
            <li><a href="${pageContext.request.contextPath}/renting/pages/onther/chat_news.jsp">消息</a></li>
            <li><a href="${pageContext.request.contextPath}/renting/pages/onther/login.jsp" style="color: #2981c8;">登录</a></li>
        </ul>
        <img src="${pageContext.request.contextPath}/renting/img/icon/lianxi-1.png" class="nav_img" style="margin-top: -20px;">
        <p class="nav_phone">
            <span>13301131116</span>
            <span>13301131116</span>
        </p>
    </div>
</div>
<div class="body">
    <div class="portrait_bg">
        <div class="portrait">
            <a href="${pageContext.request.contextPath}/renting/pages/onther/personal.jsp" class="headImg">
                <img style="width: 100px;height: 100px;border-radius: 100%" src="../../img/${drom.avater}">
            </a>
        </div>
        <p class="nickname">点击头像编辑个人资料</p>
    </div>
    <div class="content">
        <ul class="left_ul">
            <li><a href="${pageContext.request.contextPath}/renting/pages/tenant/inspection.jsp"><img src="${pageContext.request.contextPath}/renting/img/xuanzhongtiao.png" >看房记录</a></li>
            <li><a href="${pageContext.request.contextPath}/renting/pages/tenant/appointment.jsp"><img src="${pageContext.request.contextPath}/renting/img/xuanzhongtiao.png" >我的预约</a></li>
            <li><a href="${pageContext.request.contextPath}/renting/pages/tenant/order.jsp"><img src="${pageContext.request.contextPath}/renting/img/xuanzhongtiao.png" >我的订单</a></li>
            <li><a href="${pageContext.request.contextPath}/renting/pages/tenant/collection.jsp"><img src="${pageContext.request.contextPath}/renting/img/xuanzhongtiao.png" >我的收藏</a></li>
            <li class="li_active"><a href="${pageContext.request.contextPath}/renting/pages/tenant/wallet.jsp"><img src="${pageContext.request.contextPath}/renting/img/xuanzhongtiao.png" >我的钱包</a></li>
            <li><a href="${pageContext.request.contextPath}/renting/pages/tenant/ID_verification.jsp"><img src="${pageContext.request.contextPath}/renting/img/xuanzhongtiao.png" >身份验证</a></li>
            <li><a href="${pageContext.request.contextPath}/renting/pages/tenant/contract.jsp"><img src="${pageContext.request.contextPath}/renting/img/xuanzhongtiao.png" >电子合同</a></li>
            <li><a href="${pageContext.request.contextPath}/renting/pages/tenant/about.jsp"><img src="${pageContext.request.contextPath}/renting/img/xuanzhongtiao.png" >联系我们</a></li>
        </ul>
        <div class="right_body">
            <div class="right_content">
                <div class="right_title">
                    <p>我的钱包</p>
                </div>
                <div id="addContent" class="right_main">
                    <table class="table_info">
                        <tr id="tabData" valign="bottom">

                        </tr>
                        <tr>
                            <td>租龄</td>
                            <td></td>
                            <td>我的余额</td>
                            <td></td>
                            <td></td>
                        </tr>
                        <tr valign="top">
                            <td><a href="">查看历史</a></td>
                            <td><a href=""></a></td>
                            <td><a href="${pageContext.request.contextPath}/renting/pages/landlord/wallet_withdrawal.jsp">立即提现 </a><a href="${pageContext.request.contextPath}/renting/pages/landlord/wallet_budget.jsp">收支明细</a></td>
                            <td><a href=""></a></td>
                            <td><a href=""></a></td>
                        </tr>
                    </table>
                    <h4>我的账单</h4>
                    <div style="margin-top: 10px" class="stripe">
                        <span>账单类型</span>
                        <span>交租日期</span>
                        <span>支付金额</span>
                        <span>操作</span>
                    </div>

                </div>
            </div>
            <div class="right_bottom">
                <div id="test1"></div>
            </div>
        </div>
        <div style="clear: both;"></div>
    </div>
</div>
<div class="bottom">
    <p>沪公网安备 31011402005354号</p>
</div>
</body>
</html>
<script src="${pageContext.request.contextPath}/renting/js/jQuery-3.4.1.js"></script>
<script>
    $(function (){
        $.ajax({
            url:"${pageContext.request.contextPath}/contract/queryBillByUser",
            type:"post",
            data:{"rid":${drom1},"isAll":0},
            dataType:"JSON",
            success:(rs)=>{
                $.each(rs,function (i,j){
                    // console.log(j)
                    var contractDate = j.rentPaymentDate;

                    if(contractDate!=null){
                        var date = new Date(contractDate);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
                        Y = date.getFullYear() + '-';
                        M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
                        D = date.getDate();
                        contractDate = Y+M+D;
                    }
                    <%
                        request.setAttribute("nowDate",new Date().getTime());
                    %>
                    <%--alert((j.rentPaymentDate-${nowDate})/(60*60*24*1000)/30)--%>
                    let str='<a style="text-decoration: none;color: cadetblue;margin-left: 120px" disabled="" href="javascript:void(0)">未生成账单</a><br>';
                    if((j.rentPaymentDate-${nowDate})/(60*60*24*1000)/30<=1){
                        str='<a style="text-decoration: none;color: cadetblue;margin-left: 120px" href="${pageContext.request.contextPath}/contract/queryBillByPlayId?rid='+j.rid+'">去支付</a><br>';
                    }

                    var Listings=$('<div style="margin-top: 10px;border-bottom: 1px solid gray;overflow: hidden;line-height: 40px" class="con">' +
                    '<span style="float: left;margin-top: 20px;margin-left: 10px;border: 1px solid transparent;width: 200px;">租房合同</span>' +
                    '<div style="float: left;margin-left: 150px;border: 1px solid transparent;width: 100px;text-align: center;">' +
                    '<p>'+contractDate+'</p>' +
                    '</div>' +
                    '<span style="float: left;margin-top: 20px;margin-left: 120px;border: 1px solid transparent;width: 100px;text-align: center;">'+j.amount+'</span>' +
                    '<span style="float: left;margin-left: 10px;border: 1px solid transparent;width: 200px;">' +
                        str +
                    '</span>' +
                    '</div>');
                    Listings.appendTo("#addContent");
                })
            }
        });
        $.ajax({
            url:"${pageContext.request.contextPath}/order/Wallet",
            type:"post",
            async:false,
            data:{"oderUserId":${drom.rid}},
            dataType:"JSON",
            success:(data)=>{
                console.log(data);
                $("#tabData").append("<td>"+data.strData+"</td><td></td><td>￥"+data.balance+"</td><td></td><td></td>");

            }
        });
    });

</script>
<script src="${pageContext.request.contextPath}/renting/layui.js"></script>
<script src="${pageContext.request.contextPath}/renting/js/header.js"></script>
<script type="text/javascript">
    judge_login("${pageContext.request.contextPath}/renting/pages/tenant/inspection.jsp","${pageContext.request.contextPath}/renting/pages/onther/login.jsp");
</script>
<script src="${pageContext.request.contextPath}/renting/js/ScrollHolder.js"></script>